/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.der.almo.view;

import br.com.der.almo.dao.AnimalDAO;
import br.com.der.almo.dao.PessoaDAO;
import br.com.der.almo.model.Animal;
import br.com.der.almo.model.Perfil;
import br.com.der.almo.model.Pessoa;
import br.com.der.almo.util.jpaUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import static javax.swing.UIManager.get;
import javax.swing.table.DefaultTableModel;
import org.hibernate.Session;

/**
 *
 * @author thiago
 */
public class PessoaView extends javax.swing.JFrame {

    private DefaultComboBoxModel modeljcombobox  = new DefaultComboBoxModel();  
     private DefaultTableModel modelo = new DefaultTableModel();
    
    public PessoaView() {
       // desabilitarCampoId();
        preencheCombo();
       
        initComponents();
        
        tabela();
        
        monta_jTPessoa();
        desabilitarCampos();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        persistenceEntityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("persistence").createEntityManager();
        pessoaQuery = java.beans.Beans.isDesignTime() ? null : persistenceEntityManager.createQuery("SELECT p FROM Pessoa p");
        pessoaList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : pessoaQuery.getResultList();
        jInternalFrame1 = new javax.swing.JInternalFrame();
        animalQuery = java.beans.Beans.isDesignTime() ? null : persistenceEntityManager.createQuery("SELECT a FROM Animal a");
        animalList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : animalQuery.getResultList();
        jLabel1 = new javax.swing.JLabel();
        BtNovo = new javax.swing.JToggleButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTPessoa = new javax.swing.JTable();
        jPanel1 = new javax.swing.JPanel();
        BTSalvar = new javax.swing.JToggleButton();
        BTAlterar = new javax.swing.JToggleButton();
        BTExcluir = new javax.swing.JToggleButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jTCampoSenha = new javax.swing.JTextField();
        jTCampoSobrenome = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jTCampoNome = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jTCampoId = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jTCampoLogin = new javax.swing.JTextField();
        jComboBoxAniaml = new javax.swing.JComboBox();
        jLAniaml = new javax.swing.JLabel();
        jLAniaml1 = new javax.swing.JLabel();
        jComboBoxSetor = new javax.swing.JComboBox();

        jInternalFrame1.setVisible(true);

        javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
        jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
        jInternalFrame1Layout.setHorizontalGroup(
            jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jInternalFrame1Layout.setVerticalGroup(
            jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jLabel1.setText("Adcionar Pessoa");

        BtNovo.setText("Novo");
        BtNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtNovoActionPerformed(evt);
            }
        });

        jTPessoa.setModel(modelo);
        jTPessoa.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTPessoaMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTPessoa);

        jPanel1.setBackground(new java.awt.Color(204, 255, 204));

        BTSalvar.setText("Salvar");
        BTSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BTSalvarActionPerformed(evt);
            }
        });

        BTAlterar.setText("Alterar");
        BTAlterar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BTAlterarActionPerformed(evt);
            }
        });

        BTExcluir.setText("Excluir");
        BTExcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BTExcluirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addComponent(BTSalvar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(BTAlterar)
                .addGap(18, 18, 18)
                .addComponent(BTExcluir)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BTSalvar)
                    .addComponent(BTAlterar)
                    .addComponent(BTExcluir))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setBackground(new java.awt.Color(204, 204, 204));

        jLabel5.setText("Login:");

        jLabel4.setText("Sobrenome: ");

        jLabel3.setText("Nome:");

        jTCampoId.setEditable(false);

        jLabel2.setText("Id:");

        jLabel6.setText("Senha:");

        jComboBoxAniaml.setModel(modeljcombobox);

        org.jdesktop.swingbinding.JComboBoxBinding jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, animalList, jComboBoxAniaml);
        bindingGroup.addBinding(jComboBoxBinding);

        jComboBoxAniaml.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxAniamlActionPerformed(evt);
            }
        });

        jLAniaml.setText("Animal");

        jLAniaml1.setText("Setor");

        jComboBoxSetor.setModel(modeljcombobox);
        jComboBoxSetor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxSetorActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jTCampoId, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTCampoNome, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel4))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addGap(8, 8, 8)
                        .addComponent(jTCampoLogin, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTCampoSenha, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLAniaml1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBoxSetor, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jTCampoSobrenome, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(20, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLAniaml)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBoxAniaml, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(31, 31, 31))))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(jTCampoId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTCampoNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(jTCampoSobrenome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jTCampoLogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(jTCampoSenha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBoxAniaml, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLAniaml))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBoxSetor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLAniaml1))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 521, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(103, 103, 103)
                        .addComponent(jLabel1)
                        .addGap(163, 163, 163)
                        .addComponent(BtNovo, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(22, 22, 22)
                        .addComponent(jLabel1)
                        .addGap(28, 28, 28))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(BtNovo, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 67, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void BtNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtNovoActionPerformed
        
        zerarCampos();
        
       abilitarCampos();
       
    }//GEN-LAST:event_BtNovoActionPerformed

    
    
    
    //metodo para pegar os valores da linha selecionada
    private void jTPessoaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTPessoaMouseClicked
       
        int linha_selecionada = jTPessoa.getSelectedRow();
        
        jTCampoId.setText(jTPessoa.getValueAt(linha_selecionada, 0).toString());
        jTCampoNome.setText(jTPessoa.getValueAt(linha_selecionada, 1).toString());
        jTCampoSobrenome.setText(jTPessoa.getValueAt(linha_selecionada, 2).toString());
         jTCampoLogin.setText(jTPessoa.getValueAt(linha_selecionada, 3).toString());
          jTCampoSenha.setText(jTPessoa.getValueAt(linha_selecionada, 4).toString());
        
          abilitarCampos();
    }//GEN-LAST:event_jTPessoaMouseClicked

    private void BTSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BTSalvarActionPerformed
        
         Pessoa p = new Pessoa();
        
        //transformando String em Int
       // p.setId_pessoa(Integer.valueOf(jTCampoId.getText()));
        
        p.setNome(jTCampoNome.getText());
        p.setSobrenome(jTCampoSobrenome.getText());
        p.setLogin(jTCampoLogin.getText());
        p.setSenha(jTCampoSenha.getText());
        
        
        
         Animal a = (Animal) jComboBoxAniaml.getSelectedItem();
        
       
        p.setAnimal(a);
        
        
        
        
        
        PessoaDAO pdao = new PessoaDAO();
        pdao.incluir(p);
        
        monta_jTPessoa();
        zerarCampos();
        desabilitarCampos();
    }//GEN-LAST:event_BTSalvarActionPerformed

    
    
    //metodo de ação quando clicar no botão alterar
    private void BTAlterarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BTAlterarActionPerformed
       
        abilitarCampos();
        
         Pessoa p = new Pessoa();
        
        //transformando String em Int
       // p.setId_pessoa(Integer.valueOf(jTCampoId.getText()));
        p.setId_pessoa(Integer.valueOf( jTCampoId.getText()));
        p.setNome(jTCampoNome.getText());
        p.setSobrenome(jTCampoSobrenome.getText());
        p.setLogin(jTCampoLogin.getText());
        p.setSenha(jTCampoSenha.getText());
        
        PessoaDAO pdao = new PessoaDAO();
        pdao.alterar(p);
        
        
        monta_jTPessoa();
        zerarCampos();
        desabilitarCampos();
    }//GEN-LAST:event_BTAlterarActionPerformed

    private void BTExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BTExcluirActionPerformed
        
         Pessoa p = new Pessoa();
        
        //transformando String em Int
       // p.setId_pessoa(Integer.valueOf(jTCampoId.getText()));
        
        p.setId_pessoa(Integer.valueOf( jTCampoId.getText()));
        
         PessoaDAO pdao = new PessoaDAO();
        pdao.remover2(p);
        
        
        
        monta_jTPessoa();
        zerarCampos();
        desabilitarCampos();
    }//GEN-LAST:event_BTExcluirActionPerformed

    private void jComboBoxAniamlActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxAniamlActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBoxAniamlActionPerformed

    private void jComboBoxSetorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxSetorActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBoxSetorActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(PessoaView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(PessoaView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(PessoaView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(PessoaView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new PessoaView().setVisible(true);
            }
        });
    }

    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JToggleButton BTAlterar;
    private javax.swing.JToggleButton BTExcluir;
    private javax.swing.JToggleButton BTSalvar;
    private javax.swing.JToggleButton BtNovo;
    private java.util.List<br.com.der.almo.model.Animal> animalList;
    private javax.persistence.Query animalQuery;
    private javax.swing.JComboBox jComboBoxAniaml;
    private javax.swing.JComboBox jComboBoxSetor;
    private javax.swing.JInternalFrame jInternalFrame1;
    private javax.swing.JLabel jLAniaml;
    private javax.swing.JLabel jLAniaml1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTCampoId;
    private javax.swing.JTextField jTCampoLogin;
    private javax.swing.JTextField jTCampoNome;
    private javax.swing.JTextField jTCampoSenha;
    private javax.swing.JTextField jTCampoSobrenome;
    private javax.swing.JTable jTPessoa;
    private javax.persistence.EntityManager persistenceEntityManager;
    private java.util.List<br.com.der.almo.model.Pessoa> pessoaList;
    private javax.persistence.Query pessoaQuery;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

public void zerarCampos(){
    jTCampoId.setText("");
    jTCampoNome.setText("");
    jTCampoLogin.setText("");
    jTCampoSobrenome.setText("");
    jTCampoLogin.setText("");
    jTCampoSenha.setText("");
       
}


 public void tabela(){
      jTPessoa.setModel(modelo);
      
      
      modelo.addColumn("Código");
      modelo.addColumn("Nome");
      modelo.addColumn("Sobrenome");
      modelo.addColumn("login");
      modelo.addColumn("senha");
       
      modelo.addColumn("animal");
      
     
      
      jTPessoa.getColumnModel().getColumn(2).setPreferredWidth(25);
      jTPessoa.getColumnModel().getColumn(1).setPreferredWidth(180);
      jTPessoa.getColumnModel().getColumn(4).setPreferredWidth(25);
      jTPessoa.getColumnModel().getColumn(5).setPreferredWidth(25);
      
      
      //codigo para esconder uma coluna na JTable
      //Esconder alguma coluna: No Caso a Primeira Coluna
      jTPessoa.getColumnModel().getColumn(0).setMinWidth(0);
      jTPessoa.getColumnModel().getColumn(0).setPreferredWidth(0);
      jTPessoa.getColumnModel().getColumn(0).setMaxWidth(0);
      
      
      
   }
 
 
 
 private void monta_jTPessoa() {
//      Fachada f = new Fachada();
     
     PessoaDAO pdao = new PessoaDAO();
     
      ArrayList<Pessoa> lista = new ArrayList<Pessoa>();
      
      modelo.setNumRows(0);
      lista = pdao.findAll2();
      for (int i=0; i< lista.size(); i++){
         modelo.addRow(new Object[] {lista.get(i).getId_pessoa(),
                                     lista.get(i).getNome(),
                                     lista.get(i).getSobrenome(),
                                     lista.get(i).getLogin(),
                                     lista.get(i).getSenha(),
                                     lista.get(i).getAnimal()});
      }
   }
 
 
 public void abilitarCampos(){
     
     jTCampoNome.setEnabled(true);
     jTCampoSobrenome.setEnabled(true);
     jTCampoLogin.setEnabled(true);
     jTCampoSenha.setEnabled(true);
     
     
     jTCampoNome.requestFocus();
 }
public void desabilitarCampos(){
     
     jTCampoNome.setEnabled(false);
     jTCampoSobrenome.setEnabled(false);
     jTCampoLogin.setEnabled(false);
     jTCampoSenha.setEnabled(false);
     jTCampoId.setEnabled(false);
 }


public void preencheCombo(){  
         ArrayList<Animal> animais= new ArrayList<Animal>();
         AnimalDAO dao = new AnimalDAO();
         
         
        animais = dao.findAll2();
    for (int i = 0; i < animais.size(); i++){        
    modeljcombobox.addElement(animais.get(i).getId_animal());
// modeljcombobox.addElement(new Object[]{animais.get(i).getNome_animal()});
    
//         jComboBoxAniaml.addItem("TTTTTT");
// System.out.println("#######################");
//    for(Animal a : animais){
//      jComboBoxAniaml.addItem(a.getNome_animal());
            }
        }  


public void preencheComboPerfil(){
    ArrayList<Perfil> listaPerfil = new ArrayList<Perfil>();
    
}
    

   



}
